<template>
    <div class="user-body">
        <UserItem v-for="item in userList" :data="item" :key="item.id"></UserItem>
    </div>
</template>

<script setup>
    import {ref} from 'vue';
    import axios from 'axios';

    const userList = ref([]);
    const jwtToken = localStorage.getItem('jwtToken');

    const axiosInstance = axios.create({
        headers: {
            'Token': jwtToken // 将JWT令牌放入请求头的token字段
        }
    });
    axiosInstance.get('http://localhost:8080/user/showalluser')
        .then(response => {
            const responseData = response.data;
            userList.value = responseData.data;
        })
        .catch(error => {
            console.error('请求失败:', error);
        });
</script>

<style lang="scss">
    .user-body {
        background: #fff;
        padding: 15px;
    }
</style>